
#include<iostream>
#include<vector>
#define ll long long
using namespace std;
const int N = 1e5 + 5;
ll arr[N];
struct node
{
    ll data;
    ll lazy;
};
class linetree
{
public:
    linetree(ll n)
    {
        tree.resize(4 * n);
    }
    ll build(int l, int r, int pos = 0)
    {
        if (l == r)
        {
            tree[pos].data = arr[l];
            return arr[l];
        }
        int mid = l + (r - l) / 2;
        ll lsum = build(l, mid, 2 * pos + 1);
        ll rsum = build(mid + 1, r, 2 * pos + 2);
        tree[pos].data = lsum + rsum;
        return tree[pos].data;
    }

    void pushla(int pos, int len, ll k)
    {
        tree[pos].lazy += k;
        tree[pos].data += k * len;
    }

    void pushlazy(int l, int r, int pos)
    {
        ll num = tree[pos].lazy;
        if (num == 0) return;
        if (l == r)
        {
            tree[pos].lazy = 0;
            return;
        }
        int mid = l + (r - l) / 2;
        pushla(2 * pos + 1, mid - l + 1, num);
        pushla(2 * pos + 2, r - mid, num);
        tree[pos].lazy = 0;
    }

    void update(int l, int r, int ql, int qr, ll k, int pos = 0)
    {
        if (r<ql || l>qr) return;
        if (l >= ql && r <= qr)
        {
            tree[pos].data += k * (r - l + 1);
            tree[pos].lazy += k;
            return;
        }
        int mid = l + (r - l) / 2;
        pushlazy(l, r, pos);
        update(l, mid, ql, qr, k, 2 * pos + 1);
        update(mid + 1, r, ql, qr, k, 2 * pos + 2);
        tree[pos].data = tree[pos * 2 + 1].data + tree[pos * 2 + 2].data;
    }

    ll query(int l, int r, int ql, int qr, int pos = 0)
    {
        if (r<ql || l>qr) return 0;
        if (l >= ql && r <= qr) return tree[pos].data;
        int mid = l + (r - l) / 2;
        pushlazy(l, r, pos);
        return query(l, mid, ql, qr, pos * 2 + 1) + query(mid + 1, r, ql, qr, pos * 2 + 2);
    }
private:
    vector<node> tree;
};
int main()
{
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    linetree tree(n);
    tree.build(0, n - 1);
    while (m--)
    {
        int num;
        cin >> num;
        if (num == 1)
        {
            int l, r;
            ll key;
            cin >> l >> r >> key;
            tree.update(0, n - 1, l - 1, r - 1, key);
        }
        else if (num == 2)
        {
            int l, r;
            cin >> l >> r;
            cout << tree.query(0, n - 1, l - 1, r - 1) << endl;
        }
    }
    return 0;
}